# Basic Introduction

Umo Editor Server is a companion server-side software developed to enhance some features of Umo Editor Next, such as multi-user online collaborative editing, document comments, document import/export, etc. If you have already purchased the commercial license for Umo Editor Next, you can use Umo Editor Server for free under the [Umo Team Commercial Software License Agreement](../next/license).

Umo Editor Server is a Nodejs server-side software based on [Express](https://expressjs.com/?hl=zh-CN). Its main function and purpose is to enhance the capabilities of Umo Editor Next through HTTP or WebSocket interfaces, supporting private deployment.

Umo Editor Server is not distributed as an NPM package. After obtaining a commercial license, you can directly pull the source code from the private repository and modify and deploy it as needed.

## Start the Project

### 1. Clone the Official Repository
```bash
git clone <Umo Editor Server official private repository URL>
```

### 2. Install NPM Dependencies

```sh npm2yarn
npm install
```

### 3. Configure Environment Variables

Umo Editor Server does not provide unified configuration items. Some sensitive configurations are set through environment variables. Continuing the philosophy of Umo Editor's out-of-the-box experience, you only need to add a `.env` file in the project root directory and add environment variable information to quickly start. Here is an example of environment variables:

```bash filename=".env"
NODE_ENV = development

## Service related
PORT = 1235
SERVER_NAME = Umo Editor Server

## Log related
LOG_DIR = ./logs

## Database related
SQLITE_DB_PATH = ./db
SQLITE_DB_NAME = umo-editor-server.sqlite

## Collaboration related
DOC_SAVE_INTERVAL = 5000 # Unit: milliseconds

## AI related
DEEPSEEK_API_KEY = your-api-key
DEEPSEEK_API_URL = https://api.deepseek.com/v1
OPENAI_API_KEY = your-api-key
OPENAI_API_URL = https://api.openai.com/v1
MOONSHOT_API_KEY = your-api-key
MOONSHOT_API_URL = https://api.moonshot.cn/v1
```

You can also copy this information directly from `.env.example`.

### 4. Start the Project

```sh npm2yarn
npm run dev
```

### 5. All Set
 
After the above steps, you have successfully started Umo Editor Server. Visit http://127.0.0.1:1235/docs to view the Swagger documentation.

## Whitelist Configuration

Umo Editor Server provides whitelist configuration capability. If a whitelist is configured, access requests not in the whitelist will be denied.

You can add a `WHITE_LIST` environment variable in the `.env` file. The value of this environment variable is a comma-separated string, where each string represents an IP address or domain name ([URL hostname](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname) format, no protocol or port required), for example:

```bash filename=".env"
WHITE_LIST = 127.0.0.1, 0.0.0.0, localhost, example.com
```

## Development Notes

- For scenarios such as multi-user collaborative editing and document comments, Umo Editor Server provides detailed configuration and hook methods. By default, SQLite is used to store data (please use different document IDs for different documents). You can integrate or communicate with existing business systems through `database`, `redis`, `sqlite`, `webhook`, etc. For details, see the code comments.
- You can deploy Umo Editor Server as a separate service and integrate or communicate with other business systems through gateways, databases, HTTP requests, etc. Umo Editor Server currently does not include authentication implementation (but provides implementation ideas and sample code, see [Authentication Instructions](./server/auth)). If needed, please implement it yourself.
- If you need secondary development, the source code provides a large number of detailed comments that should be very helpful to you.

## Deployment Notes
- In an environment that supports `nodejs`, you can directly run the project using `npm run production`. This command provides the ability to use the `[pm2](https://pm2.io/)` daemon and record logs.
- You can also deploy the project directly to a `docker` container. You can modify the `Dockerfile` as needed.
